// Shader Variable
// (c) jimon game studio

#ifndef JEH_CSHADERVARIABLE_OPENGL
#define JEH_CSHADERVARIABLE_OPENGL

#include "IShaderVariable.h"
#include "CRender_OpenGL_Extensions.h"

#ifdef JE_RENDER_OPENGL

#include "IRender.h"
#include "IShaderMaterial.h"
#include "jeOpenGLWorkMode.h"

namespace je
{
	namespace video
	{
		//! Shader Variable
		class CShaderVariable_OpenGL:public je::video::IShaderVariable
		{
		protected:
			IRender * CurrentRender;
			IShaderMaterial * CurrentShaderMaterial;

			CRender_OpenGL_Extensions * Extensions;
			jeStringc Name;

			GLhandleARB * CurrentSP;

			u1 EnableCache;
			u1 CurrentIgnoreLocationErrors;

			GLint Location[JE_MAX_SHADER_GLOBAL_TECHNIQUES];

			OpenGLWorkMode CurrentWorkMode;
		public:
			//! Constructor
			CShaderVariable_OpenGL(IRender * Render,IShaderMaterial * ShaderMaterial,CRender_OpenGL_Extensions * NewExtensions,const jeStringc & NewName,GLhandleARB * SP,OpenGLWorkMode WorkMode,u1 IgnoreLocationErrors = false);

			//! Destructor
			~CShaderVariable_OpenGL();

			//! Get Shader Variable Name
			const jeStringc & GetName();

			//! Set Matrix
			void SetMatrix(const jeMatrix4f & Matrix);

			//! Set Matrix 3x3 (set up 3x3 part of 4x4 matrix)
			void SetMatrix3x3(const jeMatrix4f & Matrix);

			//! Set s32
			void Sets32(const s32 * Data,s32 Size);

			//! Set f32
			void Setf32(const f32 * Data,s32 Size);

			//! Set Vector Array
			void SetVector(const jeVector3df * Vector,s32 Size);

			//! Set Vector
			void SetVector(const jeVector3df & Vector);

			//! Set Vector
			void SetVector(const jeVector3di & Vector);

			//! Set Vector
			void SetVector(const jeVector2df & Vector);

			//! Set Vector
			void SetVector(const jeVector2di & Vector);

			//! Set Cached Setup
			void SetCachedSetup(u1 Enable);

			//! Is Cached Setup
			u1 IsCachedSetup();

			//! Is Exist In Shader
			u1 IsExistInShader();

			//! Get Locations
			void GetLocations();

			//! Get Current Shader Material
			IShaderMaterial * GetCurrentShaderMaterial()
			{
				return CurrentShaderMaterial;
			}
		};
	}
}

#endif

#endif
